Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update license assign view to set source for assigned licenses #526

Merged

Conversation

muhammad-ammar
Copy link
Contributor

@muhammad-ammar muhammad-ammar commented Sep 21, 2023

Description

Add support into license assign endpoint to set source for assigned licenses if salesforce ids are coming in the request.

Link to the associated ticket: https://2u-internal.atlassian.net/browse/ENT-7642

Testing considerations

  • Include instructions for any required manual tests, and any manual testing that has
    already been performed.
  • Include unit and a11y tests as appropriate
  • Consider performance issues.
  • Check that Database migrations are backwards-compatible

Post-review

Squash commits into discrete sets of changes

@muhammad-ammar muhammad-ammar marked this pull request as draft September 21, 2023 06:15
@muhammad-ammar muhammad-ammar force-pushed the ammar/update-license-assign-view-to-set-license-source branch from 54ee2ac to 1ac30c0 Compare September 22, 2023 13:38
Copy link
Contributor

@iloveagent57 iloveagent57 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, one outstanding question.

raise serializers.ValidationError('Wrong Salesforce Ids.')

# if saleforce ids list is present then not every item in the list evaluates to False
allFalse = not any(user_sfids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: snake_case instead of camelCase

if user_sfids:
# if saleforce ids list is present then its length must be equal to number of user emails
if len(user_emails) != len(user_sfids):
raise serializers.ValidationError('Wrong Salesforce Ids.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe "Number of Salesforce IDs did not match number of provided user emails." ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ... would including the number of user_emails vs. number of user_sfids be helpful in this message, too?

"Number of Salesforce IDs (X) did not match number of provided user emails (Y)."?

raise serializers.ValidationError('Wrong Salesforce Ids.')

# if saleforce ids list is present then not every item in the list evaluates to False
allFalse = not any(user_sfids)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for this check?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also curious about this, as I was a bit confused about the intent for a seemingly similar check in the associated frontend PR: openedx/frontend-app-admin-portal#1034 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah...frontend will never send such a list that will make this condition true. I think this may be overthinking on my side. I will think about this more and see if we can remove this check?

@muhammad-ammar muhammad-ammar force-pushed the ammar/update-license-assign-view-to-set-license-source branch 3 times, most recently from 9a94dc0 to 18c36af Compare September 25, 2023 12:56
@muhammad-ammar muhammad-ammar marked this pull request as ready for review September 25, 2023 12:56
@muhammad-ammar muhammad-ammar force-pushed the ammar/update-license-assign-view-to-set-license-source branch from 18c36af to c00f383 Compare September 25, 2023 13:13
@@ -769,8 +800,19 @@ def _assign(self, request, subscription_plan):
# Validate the user_emails and text sent in the data
self._validate_data(request.data)

# Dedupe all lowercase emails before turning back into a list for indexing
user_emails = list({email.lower() for email in request.data.get('user_emails', [])})
emails_and_sfids = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps set the initial variable to be an empty list so the data type is consistent throughout? The if emails_and_sfids conditional below would still work with [].

),
allow_empty=False,
required=False,
error_messages={"empty": "Wrong Salesforce Ids."}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/curious: will this error message only get returned when an empty list is provided? If so, I wonder if this error message should say something to the effect of "No Salesforce Ids provided."? Or, is this error message what appears if a given Salesforce Id doesn't pass the validators above (in which case, would a message like "Incorrect format of Salesforce Ids" make sense?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above message will come in action when we pass an empty list to api endpoint.

@muhammad-ammar muhammad-ammar force-pushed the ammar/update-license-assign-view-to-set-license-source branch from c00f383 to ab8da8d Compare September 25, 2023 16:17
@muhammad-ammar muhammad-ammar merged commit 4b0eb48 into master Sep 25, 2023
7 checks passed
@muhammad-ammar muhammad-ammar deleted the ammar/update-license-assign-view-to-set-license-source branch September 25, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants